#!/usr/bin/env python

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'login_interface.ui'
#
# Created: Thu Apr 30 02:32:04 2009
#      by: The PyQt User Interface Compiler (pyuic) 3.17.6
#
# WARNING! All changes made in this file will be lost!


from qt import *
from manager_login_form import *
from login_form import *
from sys import exit

class login_interface(QDialog):
    def __init__(self,parent = None,name = None,modal = 0,fl = 0):
        '''
        def __init__(self,parent,name,model,fl):
            this function initiate the GUI of the login interface
            and tied signals to their slots
        '''
        QDialog.__init__(self,parent,name,modal,fl)

        if not name:
            self.setName("login_interface")



        self.groupBox5 = QGroupBox(self,"groupBox5")
        self.groupBox5.setGeometry(QRect(10,10,300,130))

        self.manager_btn_login = QPushButton(self.groupBox5,"manager_btn_login")
        self.manager_btn_login.setGeometry(QRect(20,10,260,27))

        self.admin_btn_login = QPushButton(self.groupBox5,"admin_btn_login")
        self.admin_btn_login.setGeometry(QRect(20,50,260,27))

        self.cancel_btn_login = QPushButton(self.groupBox5,"cancel_btn_login")
        self.cancel_btn_login.setGeometry(QRect(20,90,260,27))

        self.languageChange()

        self.resize(QSize(327,151).expandedTo(self.minimumSizeHint()))
        self.clearWState(Qt.WState_Polished)

        self.connect(self.manager_btn_login,SIGNAL("clicked()"),self.manager_btn_login_clicked)
        self.connect(self.admin_btn_login,SIGNAL("clicked()"),self.admin_btn_login_clicked)
        self.connect(self.cancel_btn_login,SIGNAL("clicked()"),self.cancel_btn_login_clicked)


    def languageChange(self):
        '''
        languageChange(self):
            this function constructing texts of all GUI objects
        '''
        self.setCaption(self.__tr("LOGIN ABSTRACT INTERFACE"))
        self.groupBox5.setTitle(QString.null)
        self.manager_btn_login.setText(self.__tr("&Manager Login"))
        self.admin_btn_login.setText(self.__tr("&Adminstrator Login"))
        self.admin_btn_login.setAccel(QKeySequence(self.__tr("Alt+A")))
        self.cancel_btn_login.setText(self.__tr("&Cancel Login"))
        self.cancel_btn_login.setAccel(QKeySequence(self.__tr("Alt+C")))


    def manager_btn_login_clicked(self):
        '''
        manager_btn_login_clicked(self):
            this function call the manager login window
        '''
        manager_login_window = manager_login_form()
        manager_login_window.show()
        manager_login_window.exec_loop()

    def admin_btn_login_clicked(self):
        '''
        admin_btn_login_clicked(self):
            this function call the admin login window
        '''
        admin_login_window = Login_Form()
        admin_login_window.show()
        admin_login_window.exec_loop()

    def cancel_btn_login_clicked(self):
        '''
        cancel_btn_login_clicked(self):
            if we clicked this button this function will display a message box
            ask you are you surely want to exit or not
        '''
        Message = 'Are you sure you want to exit!'
        reply = QMessageBox.information(self,"Question!",Message,QMessageBox.Yes,QMessageBox.No)
        if reply == QMessageBox.Yes:
            exit()
        else:
            pass

    def __tr(self,s,c = None):
        return qApp.translate("login_interface",s,c)
